﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rabbit.Model;

namespace Rabbit.BusinessLogicLayer
{
    public class StatusCommentBL
    {
        public int currentPage = 1;
        public long StatusID { get; set; }

        private long gotRecordsCount;
        public bool CanGetNextPage
        {
            get {
                return gotRecordsCount == Utils.Configuration.PageSize;
            }
        }

        public bool CanGetPreviousePage
        {
            get {
                return currentPage > 1;
            }
        }
        private List<Comment> GetComments()
        {
            string parameters = "page=" + currentPage;
            parameters += "&count=" + Utils.Configuration.PageSize;
            
            string result = RequestHelper.SendOAuthRequest(string.Format(
                                "statuses/comments/{0}.json",
                                StatusID.ToString()), 
            parameters);
            List<Comment> tmpComment = WrappedJsonHelper.Deserialize<List<Comment>>(result);
            gotRecordsCount = tmpComment.Count;
            return tmpComment;
        }

        public List<Comment> GetFirstPageComment()
        {
            currentPage = 1;
            return GetComments();
        }

        public List<Comment> GetNextPageComment()
        {
            currentPage++;
            return GetComments();
        }

        public List<Comment> GetPreviousePageComment()
        {
            currentPage--;
            return GetComments();
        }
    }
}
